//
//  HUD.m
//  SMealUserSide
//
//  Created by apple on 2018/2/22.
//  Copyright © 2018年 yaozhengzheng. All rights reserved.
//

#import "HUD.h"
#import "UIAlterCenterView.h"
#import <SVProgressHUD.h>

@implementation HUD
+ (void)showMessage:(NSString *)message
{
    if(message.length != 0)
        [UIAlterCenterView showTimeString:message];
}

+ (void)dismissMessage
{
    [SVProgressHUD dismiss];
}

+ (void)showErrorMessage:(NSString *)message
{
    [self setupHUDInit];
    [SVProgressHUD setErrorImage:[UIImage imageNamed:@"hud_error"]];
    if(message.length != 0)
        [SVProgressHUD showErrorWithStatus:message];
    
}

+ (void)showSuccessMessage:(NSString *)message
{
    [self setupHUDInit];
    [SVProgressHUD setSuccessImage:[UIImage imageNamed:@"hud_success"]];
    if(message.length != 0)
        [SVProgressHUD showSuccessWithStatus:message];
    
}

+ (void)showInfoMessage:(NSString *)message
{
    [self setupHUDInit];
    if(message.length != 0)
        [SVProgressHUD showInfoWithStatus:message];
}


+ (void)setupHUDInit
{
    [SVProgressHUD setMinimumDismissTimeInterval:2.0];
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
    [SVProgressHUD setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.7]];
    
}

@end

@implementation HUD (LoadingAnimation)

+ (void)showDefaultLoadAnmation
{
    [self showLoadAnmaiton:YES];
}

+ (void)showLoadAnmaiton:(BOOL)animation
{
    if(animation)
    {
        [self showNoBackgroundMessage:@"努力加载中..."];
    }
}

+ (void)showNoBackgroundMessage:(NSString *)message
{
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
    [SVProgressHUD setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.3]];
    [SVProgressHUD setForegroundColor:[UIConstantColor getThemeColor]];
    if(message.length > 0)
        [SVProgressHUD showWithStatus:message];
}
//有背景的加载动画
+ (void)showLoadAnmaitonBlackGround
{
    [self showLoadBlackBackMessage:@"努力加载中..."];
}

+ (void)showLoadBlackBackMessage:(NSString *)message
{
    [SVProgressHUD setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.7]];
    [SVProgressHUD setForegroundColor:[UIConstantColor getThemeColor]];
    if(message.length > 0)
        [SVProgressHUD showWithStatus:message];
}
@end
